package com.jlpay.openapi.demo.openmerch.query;

import com.jlpay.open.jlpay.sdk.java.model.openmerch.ChannelType;
import com.jlpay.open.jlpay.sdk.java.model.openmerch.query.request.RealNameQueryRequest;
import com.jlpay.open.jlpay.sdk.java.model.openmerch.query.response.RealNameQueryResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 实名认证查询
 * @author chenjunhong
 * @since 2024/3/25
 */
public class RealNameQueryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(RealNameQueryService.class);

    public static void main(String[] args) {
        RealNameQueryRequest realNameQueryRequest = buildRealNameQueryRequest();
        RealNameQueryResponse realNameQueryResponse = JlpayOpenApiService.openMerchService()
                .post(realNameQueryRequest, RealNameQueryResponse.class);
        LOGGER.info("实名认证查询响应:{}", JsonUtils.toString(realNameQueryResponse));
    }

    private static RealNameQueryRequest buildRealNameQueryRequest() {
        RealNameQueryRequest realNameQueryRequest = new RealNameQueryRequest();
        // 商户号
        realNameQueryRequest.setMerchNo("849121653110003");
        // 查询类型，0-申请单查询（默认），1-授权结果查询
        realNameQueryRequest.setQueryType("0");
        // 00: 所有渠道，01: wechat，02: alipay
        realNameQueryRequest.setChannelType(ChannelType.ALL);
        return realNameQueryRequest;
    }

}
